Skip to content

measunit_extra.cpp: Fix error: 'abs' ambiguous#3916

Open
Dave-Allured wants to merge 1 commit intounicode-org:mainfrom
Dave-Allured:measunit.abs-fix.1
Open

measunit_extra.cpp: Fix error: 'abs' ambiguous#3916
Dave-Allured wants to merge 1 commit intounicode-org:mainfrom
Dave-Allured:measunit.abs-fix.1

Conversation

@Dave-Allured
Copy link
Copy Markdown

measunit_extra.cpp, lines 687-689:
This code is used to check an input string for a non-integer value.
With some older compilers, this generates "error: call to 'abs' is ambiguous".

        uint64_t int_result = static_cast<uint64_t>(double_result);
        const double kTolerance = 1e-9;
        if (abs(double_result - int_result) > kTolerance) {

This PR will avoid the "abs" error by replacing the handcrafted fractional test, with appropriate use of "modf".

I am not experienced with C++. Someone please check this work, thank you.

Downstream issue with complete build log: https://trac.macports.org/ticket/73705
Platform was: macOS 10.14.6 (darwin/18.7.0) arch i386
Compiler was: Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Dialect flag was: -std=gnu++11

TODO: Please read the following on ICU Contributing, and then delete these instructions.
-- Did not read. If this PR is not tolerable, let me know and I will fix.

  • We require each pull request to be associated with a Jira issue.
    -- Did not file a Jira issue.

Checklist

  • [NO] Required: Issue filed: ICU-NNNNN
  • [NO] Required: The PR title must be prefixed with a JIRA Issue number. Example: "ICU-NNNNN Fix xyz"
  • [NO] Required: Each commit message must be prefixed with a JIRA Issue number. Example: "ICU-NNNNN Fix xyz"
  • Issue accepted (done by Technical Committee after discussion)
  • [NO] Tests included, if applicable
  • [N/A] API docs and/or User Guide docs changed or added, if applicable
  • Approver: Feel free to merge on my behalf

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 27, 2026

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants